﻿<%@ Page Language="C#" MasterPageFile="~/Admin/MasterPage.master" AutoEventWireup="true"
    CodeFile="ProductSell.aspx.cs" Inherits="Admin_ProductSell" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="Server">
    <div id="page-heading">
        <h1>
            Add or Update Product Sell</h1>
    </div>
    <table border="0" width="100%" cellpadding="0" cellspacing="0" id="content-table">
        <tr>
            <th rowspan="3" class="sized">
                <img src="images/shared/side_shadowleft.jpg" width="20" height="300" alt="" /></th>
            <th class="topleft">
            </th>
            <td id="tbl-border-top">
                &nbsp;</td>
            <th class="topright">
            </th>
            <th rowspan="3" class="sized">
                <img src="images/shared/side_shadowright.jpg" width="20" height="300" alt="" /></th>
        </tr>
        <tr>
            <td id="tbl-border-left">
            </td>
            <td>
                <!--  start content-table-inner -->
                <div id="content-table-inner">
                    <table border="0" width="100%" cellpadding="0" cellspacing="0">
                        <tr valign="top">
                            <td>
                                <div style="width: 920px; float: left;">
                                    <div style="width: 460px; float: left;">
                                        <!-- start id-form -->
                                        <table border="0" cellpadding="0" cellspacing="0" id="id-form">
                                            <tr>
                                                <th valign="top">
                                                    Product Name:</th>
                                                <td>
                                                    <input type="text" style="width: 320px" id="txtName" runat="server" /><span style="color: Red">(*)</span>
                                                </td>
                                            </tr>
                                            <tr>
                                                <th valign="top">
                                                    Product Discription:</th>
                                                <td>
                                                    <div style="width: 320px">
                                                        <asp:TextBox ID="txtDescription" runat="server" MaxLength="128" TextMode="MultiLine"
                                                            Width="320" Height="100"></asp:TextBox><br />
                                                        Character Remaining <span style="color: Red">128,5 </span>line max, don't enter
                                                        HTML or Contact Details in this box
                                                    </div>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td colspan="3">
                                                    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                                                        <contenttemplate>
                                                            <table>
                                                                <tr>
                                                                    <th valign="top">
                                                                        Product Category:</th>
                                                                    <td>
                                                                        <asp:DropDownList ID="ddlProCat" Width="320" runat="server" OnSelectedIndexChanged="ddlProSubCat_OnSelectedIndexChanged"
                                                                            AutoPostBack="true">
                                                                        </asp:DropDownList><span style="color: Red">(*)</span>
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <th valign="top">
                                                                        SubCategory:</th>
                                                                    <td>
                                                                        <asp:DropDownList ID="ddlSubCat" Width="320" runat="server" OnSelectedIndexChanged="ddlSubCat_OnSelectedIndexChanged"
                                                                            AutoPostBack="true">
                                                                        </asp:DropDownList><span style="color: Red">(*)</span>
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <th valign="top">
                                                                        SubSubCategory:</th>
                                                                    <td>
                                                                        <asp:DropDownList ID="ddlSubSubCat" Width="320" runat="server">
                                                                        </asp:DropDownList><span style="color: Red">(*)</span>
                                                                    </td>
                                                                </tr>
                                                            </table>
                                                        </contenttemplate>
                                                    </asp:UpdatePanel>
                                                </td>
                                            </tr>
                                            <tr>
                                                <th valign="top">
                                                    Product Photo:</th>
                                                <td>
                                                    <div style="width: 320px">
                                                        <div style="width: 100px; float: left">
                                                            <img id="img" runat="server" width="100" height="100" />
                                                        </div>
                                                        <div style="width: 200px; float: left">
                                                            <asp:FileUpload ID="FULImg" runat="server" /><br />
                                                            <asp:Button ID="Delete" runat="server" Text="Delete" OnClick="Button1_Click" /><br />
                                                            Image format<span style="color: Red"> Jpeg, jpg, Gif,</span> or Png Size 3MB
                                                        </div>
                                                    </div>
                                                </td>
                                            </tr>
                                            <tr>
                                                <th valign="top">
                                                    Product Detail:</th>
                                                <td>
                                                    <table id="Table1" width="350px" border="0">
                                                        <tr>
                                                            <td colspan="3">
                                                                <%--OnClick="lndelete_Click"--%>
                                                                <asp:LinkButton ID="lndelete" OnClientClick="javascript: return confirm('Are you sure you want to delete this item?');"
                                                                    runat="server" CausesValidation="false" OnClick="lndelete_Click" ToolTip="Delete">Delete Product Detail</asp:LinkButton></td>
                                                        </tr>
                                                        <asp:Repeater runat="server" ID="rptAdd" OnItemDataBound="rptAdd_OnItemDataBound">
                                                            <ItemTemplate>
                                                                <tr>
                                                                    <td>
                                                                        <asp:TextBox ID="txtTitlerpt" runat="server"></asp:TextBox>
                                                                    </td>
                                                                    <td>
                                                                        <asp:TextBox ID="txtNamerpt" runat="server"></asp:TextBox>
                                                                    </td>
                                                                    <td>
                                                                        <asp:HiddenField ID="hdf" runat="server" />
                                                                        <input runat="server" onclick="select_change(this.form)" id="chkDelete" type="checkbox"
                                                                            value='<%# DataBinder.Eval(Container.DataItem, "AddMoreId") %>' name="delete" />
                                                                    </td>
                                                                </tr>
                                                            </ItemTemplate>
                                                        </asp:Repeater>
                                                    </table>
                                                    <table id="dataTable" width="350px" border="0">
                                                        <tr>
                                                            <%--<td>
                                                                <input type="checkbox" name="chk" /></td>--%>
                                                            <td>
                                                                <input type="text" id="title0" onchange="validateTitle('dataTable')" />
                                                            </td>
                                                            <td>
                                                                <input type="text" id="name0" onchange="validateName('dataTable')" />
                                                            </td>
                                                        </tr>
                                                    </table>
                                                    <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                                                        <contenttemplate>
                                                            <input type="button" value="Add Row" onclick="addRow('dataTable')" />
                                                            <input type="button" value="Delete Row" onclick="deleteRow('dataTable')" />
                                                            <input type="button" value="Getvalue" runat="server" visible="false" onclick="validateRow('dataTable')" />
                                                            <asp:Button ID="btnCreate" runat="server" Text="Save" Visible="false" OnClick="btnCreate_Click" />
                                                        </contenttemplate>
                                                    </asp:UpdatePanel>
                                                </td>
                                            </tr>
                                        </table>
                                    </div>
                                    <!-- end id-form  -->
                                    <div style="width: 460px; float: left;">
                                        <table border="0" cellpadding="0" cellspacing="0" id="id-form">
                                            <tr>
                                                <th valign="top">
                                                    KeyWord:</th>
                                                <td>
                                                    <input type="text" style="width: 340px" id="txtKeyword" runat="server" /><span style="color: Red">(*)</span>
                                                </td>
                                            </tr>
                                            <tr>
                                                <th valign="top">
                                                    Min Order Quantity:</th>
                                                <td>
                                                    <div style="width: 350px; float: left;">
                                                        <div style="width: 100px; float: left;">
                                                            <input type="text" style="width: 80px;" id="txtMinQuantity" onkeyup="this.value = FormatNumber(this.value);"
                                                                runat="server" />
                                                        </div>
                                                        <div style="width: 150px; float: left;">
                                                            <asp:DropDownList ID="ddlUnitType" Width="140" runat="server">
                                                            </asp:DropDownList>
                                                        </div>
                                                        <div style="width: 100px; float: left;">
                                                            <input type="text" style="width: 90px;" id="txtMinQuantityOther" runat="server" />
                                                        </div>
                                                    </div>
                                                </td>
                                            </tr>
                                            <tr>
                                                <th valign="top">
                                                    FOB Price:</th>
                                                <td>
                                                    <div style="width: 350px; float: left;">
                                                        <div style="width: 80px; float: left;">
                                                            <asp:DropDownList ID="ddlcurrunce" Width="70" runat="server">
                                                            </asp:DropDownList>
                                                        </div>
                                                        <div style="width: 70px; float: left;">
                                                            <input type="text" style="width: 60px;" id="txtpricesmall" onkeyup="this.value = FormatNumber(this.value);"
                                                                runat="server" />
                                                        </div>
                                                        <div style="width: 70px; float: left;">
                                                            <input type="text" style="width: 60px;" id="txtpricelarge" onkeyup="this.value = FormatNumber(this.value);"
                                                                runat="server" />
                                                        </div>
                                                        <div style="width: 120px; float: left;">
                                                            <div style="width: 30px; float: left">
                                                                Per:
                                                            </div>
                                                            <div style="width: 90px; float: left">
                                                                <asp:DropDownList ID="ddlUnitTypePrice" Width="93" runat="server">
                                                                </asp:DropDownList>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </td>
                                            </tr>
                                            <tr>
                                                <th valign="top">
                                                    Port :</th>
                                                <td>
                                                    <input type="text" style="width: 340px;" id="txtPort" runat="server" />
                                                </td>
                                            </tr>
                                            <tr>
                                                <th valign="top">
                                                    Payment Term :</th>
                                                <td>
                                                    <input type="text" style="width: 340px;" id="txtPayment" runat="server" />
                                                </td>
                                            </tr>
                                            <tr>
                                                <th valign="top">
                                                    Production Capacity :</th>
                                                <td>
                                                    <input type="text" style="width: 340px;" id="txtProCapacity" runat="server" />
                                                </td>
                                            </tr>
                                            <tr>
                                                <th valign="top">
                                                    Delivery Time :</th>
                                                <td>
                                                    <input type="text" style="width: 340px;" id="txtDeliveryTime" runat="server" />
                                                </td>
                                            </tr>
                                            <tr>
                                                <th valign="top">
                                                    Packaging Detail:</th>
                                                <td>
                                                    <textarea rows="5" id="txtPackagin" runat="server" cols="3" style="width: 340px;"></textarea></td>
                                            </tr>
                                            <tr>
                                                <th valign="top">
                                                    Member:</th>
                                                <td>
                                                    <asp:DropDownList ID="ddlMember" Width="340px" runat="server">
                                                    </asp:DropDownList></td>
                                            </tr>
                                            <tr>
                                                <th valign="top">
                                                    SortOrder:</th>
                                                <td>
                                                    <input type="text" style="width: 80px;" title="0" id="txtOrder" runat="server" onkeyup="this.value = FormatNumber(this.value);" /></td>
                                            </tr>
                                        </table>
                                    </div>
                                </div>
                                <div style="width: 930px; float: left;">
                                    <div style="width: 110px; float: left; font-weight: bold;">
                                        Detail Description:
                                    </div>
                                    <div style="width: 800px; float: left;">
                                        <FCKeditorV2:FCKeditor ID="fck_Desc" runat="server" Width="800px" ToolbarSet="RTI"
                                            Height="250px" ToolbarCanCollapse="false" BasePath="~/Javascripts/FCKEditor/">
                                        </FCKeditorV2:FCKeditor>
                                    </div>
                                </div>
                                <div style="width: 700px; margin-left: 100px; float: left; padding-top: 20px;">
                                    <asp:Button ID="btnsave" CausesValidation="true" OnClientClick="return CheckValue()"
                                        CssClass="form-submit" Text="Save" runat="server" OnClick="btnsave_Click" />
                                    <asp:Button ID="btnexit" CssClass="form-reset" Text="Reset" runat="server" OnClick="btnexit_Click"
                                        CausesValidation="False" />
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <img src="images/shared/blank.gif" width="695" height="1" alt="blank" /></td>
                            <td>
                            </td>
                        </tr>
                    </table>
                    <div class="clear">
                    </div>
                </div>
                <!--  end content-table-inner  -->
            </td>
            <td id="tbl-border-right">
            </td>
        </tr>
        <tr>
            <th class="sized bottomleft">
            </th>
            <td id="tbl-border-bottom">
                &nbsp;</td>
            <th class="sized bottomright">
            </th>
        </tr>
    </table>
    <div class="clear">
        &nbsp;</div>       
    <asp:HiddenField ID="txt" runat="server" />
    <asp:HiddenField ID="txt1" runat="server" />

    <script type="text/javascript">
            function CheckValue()
            {
                {
                
                 var ddlProCat=document.getElementById("<%=ddlProCat.ClientID%>");
                 var ddlSubCat=document.getElementById("<%=ddlSubCat.ClientID%>");
                 var ddlSubSubCat=document.getElementById("<%=ddlSubSubCat.ClientID%>");
                 var ddlMember=document.getElementById("<%=ddlMember.ClientID%>");
                 var txtName=document.getElementById("<%=txtName.ClientID%>");
                 var txtKey=document.getElementById("<%=txtKeyword.ClientID%>");
                 if(txtName.value=='')
                 {
                    alert('Name is not Null !');
                    return false;
                 }
                 if(txtKey.value=='')
                 {
                    alert('Keyword is not Null !');
                    return false;
                 }
                 if(ddlProCat.value=='0')
                 {
                    alert('Category is not Null !');
                    return false;
                 }
                 if(ddlProCat.value=='0')
                 {
                    alert('Member is not Null !');
                    return false;
                 }
                 if(ddlSubCat.value=='0')
                 {
                    alert('SubCategory is not Null !');
                    return false;
                 }
                 if(ddlSubSubCat.value=='0')
                 {
                    alert('SubsubCategory is not Null !');
                    return false;
                 }
                 
                
            }
            }
    </script>

    <script type="text/javascript" language="javascript">
    
        function addRow(tableID) {
 
            var table = document.getElementById(tableID);
            
            var rowCount = table.rows.length;
            var iteration = rowCount;
            var row = table.insertRow(rowCount);    
                   
//            var cell1 = row.insertCell(0);
//            var element1 = document.createElement("input");
//            element1.type = "checkbox";
//            cell1.appendChild(element1); 
            
            var cell2 = row.insertCell(0);
            var element2 = document.createElement("input");
            element2.type = "text";
            cell2.appendChild(element2);            
            element2.id = 'title' + iteration;
            element2.name = 'title' + iteration;
            //element2.onChange= function(){alert("It WORKED!")};
            element2.setAttribute('onChange',"validateTitle('dataTable')");
 
            var cell3 = row.insertCell(1);
            var element3 = document.createElement("input");
            element3.type = "text";
            cell3.appendChild(element3);
            element3.id = 'name' + iteration;
            element3.name = 'name' + iteration;
            //element3.onChange= function(){alert("It WORKED!")};
            element3.setAttribute('onChange',"validateName('dataTable')");
 
        };
        function deleteRow(tableID) {
            try {
            var table = document.getElementById(tableID);
            var rowCount = table.rows.length; 
            for(var i=0; i<rowCount; i++) {
                var row = table.rows[i];
                //var chkbox = row.cells[0].childNodes[0];
                //if(null != chkbox && true == chkbox.checked) {
                if(rowCount == i+1){
                    table.deleteRow(i);
                    rowCount--;
                    i--;
                } 
               
            }
            
            }catch(e) {
                alert(e);
            }
            validateRow(tableID);
        };
    function validateRow(tableID)
    {
        var table = document.getElementById(tableID);
        var rowCount = table.rows.length;             
        var txtTitle = document.getElementById('<%=this.txt.ClientID%>');
        var txtName = document.getElementById('<%=this.txt1.ClientID%>');
        txtName.value ='';
        txtTitle.value ='';
        for(var i=0; i<=rowCount; i++) 
        {            
            var row = table.rows[i];                
            var title = document.getElementById('title' + i).value;                
            var Name = document.getElementById('name' + i).value; 
               txtTitle.value += title +',';
               txtName.value += Name +',';              
        } 
    };
    
    function validateTitle(tableID)
    {
        var table = document.getElementById(tableID);
        var rowCount = table.rows.length;             
        var txtTitle = document.getElementById('<%=this.txt.ClientID%>');
        txtTitle.value='';
        for(var i=0; i<=rowCount; i++) 
        {            
            var row = table.rows[i];                
            var title = document.getElementById('title' + i).value;
               txtTitle.value += title +',';               
        } 
    };
    function validateName(tableID)
    {
        var table = document.getElementById(tableID);
        var rowCount = table.rows.length;             
        var txtName = document.getElementById('<%=this.txt1.ClientID%>');  
        txtName.value ='';      
        for(var i=0; i<=rowCount; i++) 
        {            
            var row = table.rows[i];                
            var Name = document.getElementById('name' + i).value; 
               txtName.value += Name +',';              
        } 
    };   
    </script>

</asp:Content>
